<template>
	<view>
		<block>
			<view style="height: 20rpx;"></view>
			<uni-notice-bar v-if="noticeTitle" style="margin-top: 10rpx;" :speed="50" show-icon scrollable  single :text="noticeTitle" @click="toNoticeDetail"></uni-notice-bar>

			<form>
				<view v-for="(item, index) in userForm.userList" :key="index">
					<view class="cu-form-group" style="marginTop:10rpx;">
						<view class="title" ><text class="text-red">*</text>来访人姓名</view>
						<input placeholder="请输入来访人姓名" @click="disableInput=false" name="input" v-model="item.userName"></input>
						<text class='cuIcon-delete text-red' @click="delUser(index)" v-if="userForm.userList.length>1"></text>

					</view>
					<view class="cu-form-group">
						<view class="title" ><text class="text-red">*</text>来访人联系电话</view>
						<input placeholder="请输入联系电话" @click="disableInput=false" name="input" type="number" v-model="item.userPhone"></input>
					</view>
				</view>
				<view class="text-blue btn-add" @click="addUser">
					<text class="cuIcon-add"></text>
					<text>添加人员</text>
				</view>
				<view class="cu-form-group" style="marginTop:15rpx;"  @tap="showPicker('linkage',-1,'userForm')">
					<view class="title"><text class="text-red">*</text>校内接待部门</view>
					<input placeholder="请选择接待部门名称" name="input" v-model="userForm.departName"></input>
				</view>
				<!-- <view class="text-blue btn-add" @click="addUser">
					<text class="cuIcon-add"></text>
					<text>添加人员</text>
				</view> -->

				<view class="cu-form-group" @tap="showPicker('auditPerson', -1, 'userForm')">
					<view class="title"><text class="text-red">*</text>审核人员</view>
					<input placeholder="请选择审核人员" name="input" v-model="userForm.checkUserName"></input>
				</view>
				<view class="cu-form-group">
					<view class="title"><text class="text-red">*</text>校内联系人</view>
					<input placeholder="请输入校内联系人" disabled name="input" v-model="userForm.concatName"></input>
				</view>
				<view class="cu-form-group">
					<view class="title" style="height: auto;margin: 12rpx 0;">
						<text class="text-red">*</text>
						<text>
							<text style="display: inline-block;">校内联系人</text>
							<text style="display: inline-block;">GID号</text>
						</text>
					</view>
					<input disabled="" name="input" v-model="userForm.concatGid"></input>
				</view>
				<view class="cu-form-group">
					<view class="title" style="height: auto;margin: 12rpx 0;">
						<text class="text-red">*</text>
						<text>
							<text style="display: inline-block;">校内联系人</text>
							<text style="display: inline-block;">工资号</text>
						</text>
					</view>
					<input disabled="" name="input" v-model="userForm.concatWage"></input>
				</view>
				<view class="cu-form-group">
					<view class="title"><text class="text-red">*</text>联系电话</view>
					<input placeholder="请输入校内联系人电话" name="input" v-model="userForm.concatPhone"></input>
				</view>
				<view class="cu-form-group" @tap.stop="PickerSchool('userForm')" style="marginTop:15rpx;">
					<view class="title"><text class="text-red">*</text>校区</view>
					<input placeholder="请选择校区" name="input" v-model="userForm.campus"></input>
				</view>

				<view class="cu-form-group">
					<view class="title"><text class="text-red">*</text>入校日期</view>
					<uni-datetime-picker ref="datetimePicker" :start="startDate" :end="endDate"  type="daterange" :clear-icon="false" :border="false" @change="onConfirmUser">{{userFormDateRange || '请选择日期区间'}}</uni-datetime-picker>
				</view>

				<view class="indextit"><text class="text-red">*</text>入校原因</view>
				<view class="cu-form-group align-start">
					<textarea maxlength="-1" @input="textareaBInputUser" placeholder="请输入入校原因" v-model="userForm.enrolledReason"></textarea>
				</view>
			</form>
			<view class="padding flex flex-direction">
				<button class="cu-btn bg-blue lg" @click="submituserinfoapply()" :disabled="loadModal">生成邀请码</button>
			</view>
		</block>

		<!-- 引用车牌组件 -->
		<plate-number ref="plate" v-model="plateNum" @showOrHide="showOrHide" @input="input"></plate-number>
		<view class="cu-modal" :class="modal=='DialogModal1'?'show':''">
			<view class="cu-dialog">
				<view class="cu-bar bg-white justify-end">
					<view class="content">提示</view>
					<view class="action" @tap="hideModal">
						<text class="cuIcon-close text-black"></text>
					</view>
				</view>
				<view class="padding-xl">
					确定删除此车辆？
				</view>
				<view class="cu-bar bg-white justify-end">
					<view class="action">
						<button class="cu-btn line-gray text-green" @tap="cancel">取消</button>
						<button class="cu-btn bg-blue margin-left" @tap="del">确定</button>
					</view>
				</view>
			</view>
		</view>
		<view class="cu-modal" :class="modal=='DialogModal2'?'show':''">
			<view class="cu-dialog">
				<view class="cu-bar bg-white justify-end">
					<view class="content">提示</view>
					<view class="action" @tap="hideModal">
						<text class="cuIcon-close text-black"></text>
					</view>
				</view>
				<view class="padding-xl">
					确定删除此人员申请？
				</view>
				<view class="cu-bar bg-white justify-end">
					<view class="action">
						<button class="cu-btn line-gray text-green" @tap="cancelU">取消</button>
						<button class="cu-btn  bg-blue margin-left" @tap="delU">确定</button>
					</view>
				</view>
			</view>
		</view>
		<view class="cu-modal" :class="modal=='DialogModal3'?'show':''">
			<view class="cu-dialog">
				<view class="cu-bar bg-white justify-end">
					<view class="content">提示</view>
					<view class="action" @tap="hideModal">
						<text class="cuIcon-close text-black"></text>
					</view>
				</view>
				<view class="padding-xl">
					{{dateTip}}
				</view>
				<view class="cu-bar bg-white justify-end">
					<view class="action">
						<button class="cu-btn bg-blue" @tap="openDatePicker">确定</button>
					</view>
				</view>
			</view>
		</view>
		<view class="cu-modal" :class="modal=='DialogModal4'?'show':''">
			<view class="cu-dialog">
				<view class="cu-bar bg-white justify-end">
					<view class="content">提示</view>
					<view class="action" @tap="hideModal">
						<text class="cuIcon-close text-black"></text>
					</view>
				</view>
				<view class="padding-xl">
					时间区域不能大于七天，请重新选择
				</view>
				<view class="cu-bar bg-white justify-end">
					<view class="action">
						<button class="cu-btn bg-blue" @tap="showPicker('range')">确定</button>
					</view>
				</view>
			</view>
		</view>
		<view class="cu-load loading loadingfixed text-blue round" :class="loadModal?'show':''"></view>
		<w-picker mode="range" startYear="2020" endYear="2030" :current="true" @confirm="onConfirmUser($event,'range')"
		 @cancel="onCancel" ref="rangeuser"></w-picker>
		<w-picker mode="range" startYear="2020" endYear="2030" :current="true" @confirm="onConfirm($event,'range')" @cancel="onCancel"
		 ref="range"></w-picker>
		<w-picker mode="linkage" :value="defaultRegion1" :options="options" :level="2" :default-props="defaultProps1"
		 @confirm="onConfirmLinkage($event,'linkage')" @cancel="onCancel" ref="linkage"></w-picker>
		<w-picker mode="selector" :value="defaultRegion1" :options="auditPersons" :default-props="defaultProps2"
		  @confirm="onConfirmAuditPerson($event,'auditPerson')" @cancel="onCancel" ref="auditPerson"></w-picker>
		<w-picker mode="region" :value="defaultRegion" default-type="value" :hide-area="false" @confirm="onConfirmRegion($event,'region')"
		 @cancel="onCancel" ref="region"></w-picker>
		 <w-picker mode="region" :value="defaultRegion" default-type="value" :hide-area="false" @confirm="onConfirmPassRegion($event,'region')"
		  @cancel="onCancel" ref="region2"></w-picker>
		<multiple-select v-model="show" :default-selected="defaultSelected" :data="xiaoqu" @confirm="confirmXiaoqu"></multiple-select>
		<view class="modal" v-if="showNotice">
			<view class="mask">
			</view>
			<view class="container">
				<view class="title">申请须知</view>
                <view class="content">
                   <view>1、确因工作需要进校的来访人员，按照“谁邀请、谁负责，谁主管、谁负责”的原则，由校内邀请人（联系人）通过本平台进行人员、车辆入校申请；</view>
                   <view>2、本平台仅限教职工使用，实行分类审核。人员和车辆（轿车、中小型货车、中小型客车）由校内申请人所在单位审核通过后，审核流程结束，访客凭有效身份证件和短信（含二维码链接）刷码或身份证进校；大型客车、中小型工程车、大型工程车非工作日进校）仍将推送至保卫与校园管理处审核，访客凭有效身份证件和短信（含二维码链接）刷码或身份证进校。以上若为团体进校仍将推送至保卫与校园管理处审核；</view>
                   <view>3、不接待任何商业旅游团；</view>
                   <view>4、特种车辆（包括但不限于叉车、吊车、铲车等）及大型货车（车长超过6m且总质量4500千克以上），原则上工作日不能进校；如有紧急情况，工作日入校需校内联络单位线下提交由单位主要负责人签字、盖章的纸质申请单（制式模板见官网《特种车辆及大型货车入校备案须知》）。进校时间应避开上下班（学）高峰期（7：30-8：30，13：50-14：20，17：30-18：20）；</view>
                   <view>5、若访客车辆、人员较多，可选择批量导入，详情见填写界面；</view>
                   <view>6、申请人所填访客信息、进校事由等必须真实准确，不得造假；</view>
                   <view>7、如遇学校重大活动，将视情况动态管理；</view>
                   <view>8、申请从事采访、拍摄、录制等活动人员进校，进校人员需随身携带校内申请单位发放的采访证或备案表（需备注校内联系人相关信息），以便联系；</view>
                   <view>9、申请施工人员、车辆进校，需在入校原因中明确施工具体楼栋及门牌号；</view>
                   <view>10、来访人员、车辆进入校园，自觉遵守相关校园交通管理规定，车辆进校后必须按照校园交通标志行驶，按照泊位或指定位置停放，严禁占用主干道或随意停放车辆，不得鸣笛，车速不得超过20km/h，且驾驶员联系方式置于车辆前挡风玻璃处醒目位置；</view>
                   <view>11、严禁上传涉密、违反法律法规及包含不良信息的文件；</view>
                   <view>12、校外来访车辆严禁在校内充电；</view>
                   <view>13、前往东校区的轿车，请从东校区黄山路北门驶入，停放在老北门外停车场或划线停车位，感谢您的配合；</view>
                   <view>14、如有其他疑问，请咨询保卫与校园管理处0551-63600083。</view>
                </view>
				<button :disabled="!canClick" :class="canClick && 'active'" type="default" @click="showNotice=false">已阅读{{ times>0 ? `(${times}s)`:''}}</button>
			</view>
		</view>

		<view class="my_invite" @click="toRecord">
			<text>我的</text><text>邀请</text>
		</view>
	</view>
</template>

<script>
	import multipleSelect from "@/components/multiple-select/multiple-select"
	import wPicker from "@/components/w-picker/w-picker.vue"
	import baseUrl from '../../api/api.js'
	import energy from '@/static/energy.png'
	import plateNumber from '@/components/plate-number/plateNumber.vue';
	import ClipboardJS from 'clipboard'
	import {dateFormat} from '@/common/utils.js'



	let Base64 = require('js-base64').Base64
	export default {
		components: {
			plateNumber,
			wPicker,
			multipleSelect,
		},
		data() {
			return {
				imageStyle:{
					"height": 100,	// 边框高度
					"width": 100,	// 边框宽度
					"border":{ // 如果为 Boolean 值，可以控制边框显示与否
						"color":"#eee",		// 边框颜色
						"width":"1px",		// 边框宽度
						"style":"solid", 	// 边框样式
						"radius":"10" 		// 边框圆角，支持百分比
					}
				},
				imageValue: [],
				defaultProps1: {
					label: "departName",
					value: "deptId",
					children: "departList"
				},
				defaultProps2: {
					label: "checkUserName",
					value: "checkUserGid",
					// children: "departList"
				},
				defaultSelected: [],
				index: 0,
				defaultRegion1: [],
				options: [],
				show: false,
				defaultRegion: ["340000", "340100", "340104"],
				userFormDateRange: '年/月/日',
				formDateRange: '年/月/日',
				numArr:  Array.from({length: 23}, (_, index) => index + 1).map(item => ({value: item+'时'})),
				carIndex: 0,
				loadModal: false,
				modal: null,
				isSumbituser: false,
				isSumbituserInfo: false,
				userForm: {
					checkUserName: '',
					checkUserGid: '',
					checkUserEmail: '',
					userList: [{
						userName: '',
						userPhone: ''
					}],
					departName: '',
					deptId: '',
					concatName: '',
					concatPhone: '',
					campus: '',
					campusId: '',
					campusDoor: '',
					enrolledTime: '',
					endDate: '',
					enrolledDateTime: '请输入具体时间',
					enrolledReason: '',
					concatGid: '',
				},
				modalName: null,
				campus: null,
				CarModelList: [{
					name: '请选择车型',
					code: ''
				}],
				xqindex: -1,
				PXQindex: -1,
				xiaoqu: [],
				typeindex: 0,
				carType: [{
					name: '请选择身份类型',
					code: ''
				}],
				TabCur: '1',
				list: ['人员申请'],
				dialog: null,
				plateNum: '',
				keyword: '',
				result: [],
				numIndex: null,
				userIndex: 0,
				name: null,
				openId:null,
				ticket:null,
				energy: '', //新能源图标的地址
				canClick: false ,// 已阅读是否可以点击
				showNotice: false,
				times: process.env.NODE_ENV === 'production' ? 3 : 0,
				auditPersons: [],
				disableInput: false,
				noticeTitle: '',
				banDate: [],
				dateTip: '',
				startDate: dateFormat(new Date(), 'yyyy-MM-dd'),
				endDate: dateFormat(new Date(Date.now() + 3600000*24*60), 'yyyy-MM-dd')
			}
		},
		onShow() {
			this.energy = energy;
			// this.disableInput = false
		},
		mounted() {
			this.$nextTick(() => {
				this.clipboard = new ClipboardJS('.btn1');
				this.clipboard.on('success', (e) => {
					e.clearSelection();
					uni.showToast({
						title: '复制成功',
						icon: 'none'
					})
				});
			})
		},
		onLoad() {
			this.getLimitDate()
			this.getNoticeList()
			this.params = window.location.href.split('?')[1] || ''

			if(this.getParam(location.href, "error")) {
				return uni.showModal({
				  content: decodeURIComponent(Base64.decode(this.getParam(location.href, "error"))),
				  showCancel: true,
				  confirmText:'切换其他账号',
				  cancelText: '我知道了',
				  success: (res) => {
					if(res.confirm) {
					  window.location.href = "https://passport.ustc.edu.cn/login?renew=true&service=http%3A%2F%2Fbwclf.ustc.edu.cn%2Fassets%2Fstatic%2F%23%2Fpages%2Fentry%2Fentry";
					} else {
					  window.location.href = "https://passport.ustc.edu.cn/login";

					}
				  }
				})
			}
	
			this.openId = this.getParam(location.href, "openId")
			this.concatName = decodeURIComponent(Base64.decode(decodeURIComponent(this.getParam(location.href, "concatName"))))
			this.concatWage = decodeURIComponent(Base64.decode(decodeURIComponent(this.getParam(location.href, "concatWage"))))
			this.concatGid = Base64.decode(decodeURIComponent(this.getParam(location.href, "concatGid")))

			this.userForm.concatName = this.concatName
			this.userForm.concatGid = this.concatGid
			this.userForm.concatWage = this.concatWage

			if(process.env.NODE_ENV === 'development') {
				this.openId = 'oDejQ1PUEBrk010l_hrXhzYgFLss'
			}

			this.getOPenid()
		},
		methods: {
			openDatePicker() {
				this.$refs.datetimePicker.show()
				this.modal = ''
			},
			getLimitDate() {
				uni.request({
					url: baseUrl.baseUrl + "zkd/getLimitDate",
					method: 'GET',
					header: {
						'content-type': 'application/x-www-form-urlencoded' //自定义请求头信息
					},
					success: (res) => {
						this.banDate = res.data.data.split('   |   ')
						console.log('this.banDate', this.banDate);
					}
				})
			},
			delUser(index) {
				console.log(index)
				this.modal = "DialogModal2"
				this.dialog = index
			},
			delU() {
				this.userForm.userList.splice(this.dialog, 1)
				this.modal = null
			},
			cancelU() {
				this.modal = null
			},
			addUser() {
				this.userForm.userList.push({
					userName: '',
					userPhone: ''
				})
				this.$forceUpdate()
			},
			toNoticeDetail() {
				uni.navigateTo({
					url: '/pages/employee/noticeDetail'
				})
				uni.setStorageSync('notice', this.notice)
			},
			getNoticeList() {
				uni.request({
					url: baseUrl.baseUrl + "zkd/notice/list",
					method: 'GET',
					header: {
						'content-type': 'application/x-www-form-urlencoded' //自定义请求头信息
					},
					success: (res) => {
						console.log(res);
						this.noticeTitle = res.data.data.length ? res.data.data[0].title : ''
						this.notice = res.data.data ? res.data.data[0] : ''
					}
				})
			},
			toRecord() {
				uni.navigateTo({
					url: '/pages/invite/record' + `?${this.params}`
				})
			},
			getOPenid(){
				if(this.openId){
					console.log(this.openId)
					this.getCARModel()
					this.getCampus()
					this.getCARType()
					this.getOrgan()
				} else{
					uni.setStorageSync('flag',1)
					window.location.href = "https://passport.ustc.edu.cn/login?service=http://bwclf.ustc.edu.cn/weixin/getOauthUrl";
				}
			},
			submituserinfoapply() {
				console.log('submituserinfoapply', this.userForm);
				let one = this.auditPersons.find(item => item.checkUserGid === this.userForm.checkUserGid)
				if (one) {
					// 尝试解决 checkUserName 和 checkUserGid 不一致的bug
					this.userForm.checkUserName = one.checkUserName
					this.userForm.checkUserEmail = one.checkUserEmail
				}

				let flag = this.userForm.userList.findIndex(item => item.userName=='' || item.userPhone=='')
				if (flag!=-1) {
					uni.showModal({
						title: '提示',
						content: '请输入正确的来访人联系名称及电话',
						showCancel: false
					});
					return
				} else if (this.userForm.departName === '') {
					uni.showModal({
						title: '提示',
						content: '请输入校内接待部门名称',
						showCancel: false
					});
					return
				} else if (this.userForm.checkUserName === '' || this.userForm.checkUserName === null) {
					uni.showModal({
						title: '提示',
						content: '请输入校审核人员',
						showCancel: false
					});
					return
				} else if (this.userForm.concatName === '') {
					uni.showModal({
						title: '提示',
						content: '请输入校内联系人',
						showCancel: false
					});
					return
				} else if (this.userForm.concatPhone === '') {
					uni.showModal({
						title: '提示',
						content: '请输入校内联系人电话',
						showCancel: false
					});
					return
				} else if (this.userForm.campusId === ''  || this.userForm.campusId === 'undefined') {
					uni.showModal({
						title: '提示',
						content: '请选择校区',
						showCancel: false
					});
					return
				} else if (this.userForm.enrolledReason === '') {
					uni.showModal({
						title: '提示',
						content: '请输入入校原因',
						showCancel: false
					});
					return
				} else if (this.userForm.enrolledTime === '') {
					uni.showModal({
						title: '提示',
						content: '请输入入校日期',
						showCancel: false
					});
					return
				} else {
					var startU = new Date(this.userForm.enrolledDate.replace('-', '/')+' 00:00:00').getTime()
					var endU = new Date((this.userForm.endTime || this.userForm.endDate).replace('-', '/')+' 00:00:00').getTime()

					if (Math.floor(endU / (24 * 3600 * 1000)) - Math.floor(startU / (24 * 3600 * 1000)) > 7) {
						this.modal = 'DialogModal3'
						this.dateTip = '入校时间区域不能大于七天，请重新选择'
						return
					}

					let arr = []
					var that = this
					that.loadModal = true
					uni.request({
						url: baseUrl.baseUrl + "zkd/teacher/invite",
						data: {
							...this.userForm,
							enrolledHour: '',
							openId:that.openId,
							ticket:that.ticket,
							concatGid: decodeURIComponent(that.getParam(location.href, "concatGid")) || that.userForm.concatGid,
							concatName: decodeURIComponent(that.getParam(location.href, "concatName")) || that.userForm.concatName,
							concatWage: decodeURIComponent(that.getParam(location.href, "concatWage")) || that.userForm.concatWage,
							source: decodeURIComponent(that.getParam(location.href, "source"))

						},
						method: 'POST',
						header: {
							'content-type': 'application/json' //自定义请求头信息
						},
						success(res) {
							console.log(res)
							if (res.data.code === 200) {
								that.loadModal = false

								that.PXQindex = -1
								that.userFormDateRange = '年/月/日'
								that.userForm = {
									userPhone: '',
									checkUserName: '',
									checkUserId: '',
									checkUserGid: '',
									departName: '',
									deptId: '',
									concatName: '',
									concatPhone: '',
									campus: '',
									campusId: '',
									campusDoor: '',
									enrolledTime: '',
									endDate: '',
									enrolledDateTime: '',
									enrolledReason: ''
								}
								uni.pageScrollTo({
									scrollTop: 0,
									duration: 300
								});
								uni.showModal({
									title: '提示',
									content: '邀请码已生成，已以短信的方式发至访客。',
									showCancel: false,
									success: () => {
										setTimeout(()=>{
											window.location.href = window.location.href
										},500)
									}
								})
							} else {
								uni.showModal({
									title: '提示',
									content: res.data.message,
									showCancel: false
								});
								that.loadModal = false
								if (!that.userForm.enrolledDateTime) {
									that.userForm.enrolledDateTime = '请输入具体时间'
								}
							}
						},
						fail(err) {
							console.log(err)
						}
					})
				}
			},
			getParam(path, name) {
				var reg = new RegExp("(^|\\?|&)" + name + "=([^&]*)(\\s|&|$)", "i");
				if (reg.test(path))
					return decodeURIComponent(RegExp.$2.replace(/\+/g, " "));
				return "";
			},
			PickerSchool(val) {
				document.activeElement.blur();
				this.show = true
				this.campus = val === 'userForm' ? 'userForm' : null
				console.log(this.userForm)
			},
			onConfirmLinkage(res, type) {
				console.log('this.userForm', this.userForm);
				console.log(res);
				this.userForm.departName = res.obj.col2.departName
				let arr = res.value
				this.userForm.deptId = arr[1];
				this.userForm.checkUserName = null;
				this.userForm.checkUserGid = null;
				this.userForm.checkUserEmail = null;
				this.getAuditPerson()
			},
			onConfirmAuditPerson(res, type) {
				console.log(res,this.name)
				this.userForm.checkUserName = res.obj.checkUserName;
				this.userForm.checkUserGid = res.obj.checkUserGid;
				this.userForm.checkUserEmail = res.obj.checkUserEmail;
				this.userForm.checkUserId = res.value;
				let one = this.auditPersons.find(item => item.checkUserGid === this.userForm.checkUserGid)
				if (one) {
					// 尝试解决 checkUserName 和 checkUserGid 不一致的bug
					this.userForm.checkUserName = one.checkUserName
					this.userForm.checkUserEmail = one.checkUserEmail
				}
				this.$forceUpdate()
			},
			//获取车型
			getCARModel() {
				var that = this
				uni.request({
					url: baseUrl.baseUrl + "rest/dict/getdictlist",
					data: {
						code: 'CarModel'
					},
					method: 'POST',
					header: {
						'content-type': 'application/x-www-form-urlencoded' //自定义请求头信息
					},
					success(res) {
						console.log(res.data)
						that.CarModelList = res.data.data
						console.log(that.CarModelList)
					},
					fail(err) {
						console.log(err)
					}
				})
			},
			//获取Campus
			getCampus() {
				var that = this
				uni.request({
					url: baseUrl.baseUrl + "rest/dict/getdictlist",
					data: {
						code: 'Campus'
					},
					method: 'POST',
					header: {
						'content-type': 'application/x-www-form-urlencoded' //自定义请求头信息
					},
					success(res) {
						let xiaoqu = []
						res.data.data.forEach(item => {
							var json = {
								label: item.name,
								value: item.code
							}
							xiaoqu.push(json)
						})
						that.xiaoqu = xiaoqu
					},
					fail(err) {
						console.log(err)
					}
				})
			},
			showPicker(type, index, name) {
				document.activeElement.blur();
				if (name) {
					this.name = name
				} else {
					this.name = null
				}
				console.log(index)
				if (index < 0) {
					this.numIndex = null
				} else {
					this.numIndex = index
				}
				this.modal = ''
				this.$refs[type].show();
			},
			//获取证件类型
			getCARType() {
				console.log(baseUrl.baseUrl)
				var that = this
				uni.request({
					url: baseUrl.baseUrl + "rest/dict/getdictlist",
					data: {
						code: 'CardType'
					},
					method: 'POST',
					header: {
						'content-type': 'application/x-www-form-urlencoded' //自定义请求头信息
					},
					success(res) {
						that.carType = res.data.data
					},
					fail(err) {
						console.log(err)
					}
				})
			},
			//获取校外部门
			getOrgan() {
				var that = this
				uni.request({
					url: baseUrl.baseUrl + "rest/dept/getsysdeptlist",
					method: 'GET',
					header: {
						'content-type': 'application/x-www-form-urlencoded' //自定义请求头信息
					},
					success(res) {
						that.options = res.data.data
					},
					fail(err) {
						console.log(err)
					}
				})
			},
			getAuditPerson() {
				var that = this
				uni.request({
					url: baseUrl.baseUrl + "rest/dept/getOrgJobList",
					method: 'GET',
					header: {
						'content-type': 'application/x-www-form-urlencoded' //自定义请求头信息
					},
					data: {
						deptId: this.userForm.deptId
					},
					success(res) {
						console.log(res.data.data)
						that.auditPersons = null
						that.$nextTick(() => {
							that.auditPersons = res.data.data
						})
					},
					fail(err) {
						console.log(err)
					}
				})
			},
			confirmXiaoqu(data) {
				if (this.campus) {
					this.userForm.campus = data.map((el) => el.label).join(" ");
					this.userForm.campusId = data.map((el) => el.value).join(",");
				} else {
					this.form.campus = data.map((el) => el.label).join(" ");
					this.form.campusId = data.map((el) => el.value).join(",");
				}
			},
			textareaBInput(e) {
				this.form.enrolledReason = e.detail.value
			},
			textareaBInputUser(e) {
				this.userForm.enrolledReason = e.detail.value
			},
			onConfirmUser(value) {
				var startU = new Date((value[0] + ' 00:00:00').replace('-', '/')).getTime()
				var endU = new Date((value[1] + ' 00:00:00').replace('-', '/')).getTime()
				let index = this.banDate.findIndex(item=>  {
					return new Date(item.replace('-', '/')) >= startU && new Date(item.replace('-', '/')) <= endU
				})
				if (Math.floor(endU / (24 * 3600 * 1000)) - Math.floor(startU / (24 * 3600 * 1000)) > 7) {
					this.modal = 'DialogModal3'
					this.dateTip = '时间区域不能大于七天，请重新选择'
				} else if (index != -1) {
					this.modal = 'DialogModal3'
					this.dateTip = `所选入校时间含不可预约日期，详情请见公告栏`
					console.log(this.dateTip);
				} else {
					this.userForm.enrolledDate = value[0]
					this.userForm.enrolledTime = value[0]
					this.userForm.endTime = value[1]
					this.userForm.endDate = value[1]
					this.userFormDateRange = `${value[0]} 至 ${value[1]}`;
				}
			},
		}
	}
</script>

<style lang="scss">
	::v-deep .dialog-close {
		display: none;
	}
	.title {
		width: 260rpx;
	}
	.my_invite {
		position: fixed;
		background: #004d95;
		color: #fff;
		width: 100rpx;
		height: 100rpx;
		border-radius: 50%;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		bottom: 80rpx;
		right: 10rpx;
		z-index: 101;
	}
	.indextit {
		padding: 20rpx;
	}
	.loadingfixed {
		width: 200rpx;
		height: 200rpx;
		display: block;
		position: fixed;
		top: 50%;
		left: 50%;
		margin-top: -100rpx;
		margin-left: -100rpx;
		line-height: 100px;
		background: rgba(0, 0, 0, 0.1);
		display: none;
	}
	.show {
		display: block;
	}
	.btn-add {
		text-align: center;
		background: white;
		height: 42px;
		line-height: 42px;
		border-top: 1rpx solid #eee;
	}
</style>
